<template>
  <div>
    <h2>{{this.$root.testname}}</h2>
    <h3>{{msg}}</h3>
    <button @click="getRootMethods">获取root方法</button>
  </div>
</template>

<script>
export default {
  name: "root",
  data() {
    return {
      msg: "",
    };
  },
  methods: {
    getRootMethods() {
      this.msg = this.$root.testMethods();
    },
  },
};
</script>